﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="reject.aspx.cs" Inherits="OpenRAMS.Community.deny" %>
<%@ Import Namespace="OpenRAMS.Model" %>

<!DOCTYPE html>

<html>
<head runat="server">
    <title>OpenRAMS - Rejection Page</title>
    <%
        //This page should never render in the browser.

        //Verify a parameter was sent
        String approveRequest = "";
        try
        {
            approveRequest = Request.QueryString["bID"].ToString();
        }
        catch { Response.Redirect("Community.aspx"); }

        //verify parameter sent is of integer type
        int bookingID = -1;
        try
        {
            bookingID = Convert.ToInt32(approveRequest);
        }
        catch { Response.Redirect("Community.aspx"); }

        //Verify user is in Community role (if they aren't send them back to home)
        if (!User.IsInRole("community") && !User.IsInRole("admin")) { Response.Redirect("~/Staff/Staff.aspx"); }

        //Attempt to find the booking
        Booking bookingToApprove = new Booking();
        int result = bookingToApprove.Load(bookingID);

        //if not found, send back
        if (result < 0) { Response.Redirect("Community.aspx"); }
        
        //Do the necessary & save changes
        bookingToApprove.bookActive = false;
        bookingToApprove.bookStatus = "Rejected";
        bookingToApprove.bookApproved = false;
        bookingToApprove.Save();

        Response.Redirect("Community.aspx"); 
         %>

</head>
<body>
    <form id="form1" runat="server">
    <div>
    
    </div>
    </form>
</body>
</html>
